import 'package:flutter/material.dart';
import 'package:flutter_audit_app/res/strings.dart';
import 'package:flutter_audit_app/routes/fluro_navigator.dart';

import 'loading_dialog.dart';

///弹窗管理组件
class DialogManager {
  static LoadingDialog _dialog;

  static void showBasicDialog(BuildContext context,
      {String msg = Strings.loadingTxt}) {
    _dialog = LoadingDialog(text: msg);
    showDialog<Null>(
        context: context, //BuildContext对象
        barrierDismissible: false,
        builder: (BuildContext context) {
          return _dialog;
        });
  }

  ///界面跳转后关闭dialog可以使用它
  static void dismissDialog(BuildContext context) {
    NavigatorUtils.goBack(context);
  }

  ///正常关闭dialog
  static void dismiss() {
    _dialog.dismiss();
  }
}
